#include <iostream>
#include <exception>
#include <fstream>
#include <sstream>
using namespace std;

//"jast as in life , choice is hard"
int main()
{
    try {
        int i = 0;
        ofstream* pofs;
        for (;;) {
            ostringstream ss;
            ss << i << ".txt";
            pofs = new ofstream (ss.str().c_str());
            *pofs << "Test i" << endl;
            cout << "Open file: " << i++ << endl;
        }
    }
    
    catch (...){
        cerr << "M e m o r y e x h a u s t e d !";
    }
}


    
    
